package org.kisekiproject.actions {
	import flash.utils.Dictionary;

	public class ActionController {

		private var _actionByName:Dictionary;

		/**
		 * Constructor.
		 */
		public function ActionController() {
			_actionByName=new Dictionary();
		}

		/**
		 * Call action.
		 */
		public function callAction(name:String, parameters:Object):void {
			var action:Action=_actionByName[name];

			if (!action)
				throw new Error("Action doesn't exist: "+name);

			action.call(parameters);
		}

		/**
		 * Does the action exist?
		 */
		public function hasAction(name:String):Boolean {
			var o:Object=_actionByName[name];

			return o!=null;
		}

		/**
		 * Use function.
		 */
		public function addFunction(object:Object, name:String, parameters:Array):void {
			_actionByName[name]=new Action(object, name, parameters);
		}
	}
}